//
//  FirstAuditingVC.m
//  优学荟管理系统
//
//  Created by 星道 on 17/7/10.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "FirstAuditingVC.h"
#import "FirstAuditingHeaderView.h"
#import "OrdinaryHomeCell.h"
#import "FirstAuditingGetMoneyVC.h"
#import "LoginVC.h"
@interface FirstAuditingVC ()

/**
 数据存放 @[@"Title":@"",@"Img":@""]
 */
@property (nonatomic, strong) NSArray <NSDictionary *>*DataArr;
@end

@implementation FirstAuditingVC


- (void)viewDidLoad
{
    [super viewDidLoad];

    // 配置TableView
    [self SetupTableView];

}



#pragma mark  - 配置
/**
 配置TableView
 */
- (void)SetupTableView
{
    // 占位
    self.tableView.tableFooterView = [UIView new];
    self.tableView.tableHeaderView = [UIView new];
    // 预注册
    [self.tableView registerNib:[UINib nibWithNibName:[OrdinaryHomeCell description] bundle:nil] forCellReuseIdentifier:@"Cell"];
    // 预估高度
    self.tableView.rowHeight = 64;
}







#pragma mark - TableView代理
//区
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

//行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.DataArr.count;
}

//Cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    OrdinaryHomeCell *Cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    //取值
    NSDictionary *Dict = self.DataArr[indexPath.row];
    // 点语法
    Cell.Dict = Dict;
    return Cell;
}

//区头
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    FirstAuditingHeaderView *HeaderView = [[[NSBundle mainBundle] loadNibNamed:[FirstAuditingHeaderView description] owner:nil options:nil] lastObject];
    HeaderView.userNameLabel.text     = [NSString stringWithFormat:@"%@(%@)",[AccountTool shareAccountTool].currentAccount.petName,[AccountTool shareAccountTool].currentAccount.username];
    
    return HeaderView;
}

//区高
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 150 * KScale;
}

// 行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 64;
}

//单击行事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 处理TableView的点击事件
    [self MgrTableView:tableView DidSelectRowAtIndexPath:indexPath];
}





#pragma mark - 处理点击事件
/**
 处理TableView的点击事件
 */
- (void)MgrTableView:(UITableView *)TableView DidSelectRowAtIndexPath:(NSIndexPath *)IndexPath
{
    // 资金提现审核
    if (IndexPath.row == 0)
    {
        FirstAuditingGetMoneyVC *VC = [[FirstAuditingGetMoneyVC alloc] init];
        // 我是资金方
        VC.FirstAuditingGetMoneyType = FirstAuditingGetMoney;
        VC.title = @"资金提现审核";
        [self.navigationController pushViewController:VC animated:YES];
    }
    // 星币提现
    else if (IndexPath.row == 1)
    {
        FirstAuditingGetMoneyVC *VC = [[FirstAuditingGetMoneyVC alloc] init];
        // 我是星币方
        VC.FirstAuditingGetMoneyType = FirstAuditingGetMoneyCoins;
        VC.title = @"星币提现审核";
        [self.navigationController pushViewController:VC animated:YES];
    }else if (IndexPath.row == 2){
        
        FirstAuditingGetMoneyVC *VC = [[FirstAuditingGetMoneyVC alloc] init];
        // 我是套餐提现审核
        VC.FirstAuditingGetMoneyType = FirstAuditingGetMoneyCoinsTaocan;
        VC.title = @"套餐提现审核";
        [self.navigationController pushViewController:VC animated:YES];
        
    }else if (IndexPath.row == 3){
      
        ZYalertController *alert = [ZYalertController alertControllerWithTitle:@"温馨提示" message:@"是否退出登录？" preferredStyle:(UIAlertControllerStyleAlert)];
        ZYAlertAction *action = [ZYAlertAction actionWithTitle:@"取 消" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        ZYAlertAction *actionTow = [ZYAlertAction actionWithTitle:@"确 定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
            [self.navigationController pushViewController:[LoginVC new] animated:YES];
        }];
        
        [alert addAction:action];
        [alert addAction:actionTow];
        action.textColor = [UIColor blackColor];
        actionTow.textColor = [UIColor blackColor];
        
        
         [self presentViewController:alert animated:YES completion:nil];
        
        
        
        
        
        
    }
    // 没有
    else
    {
    }
}







#pragma mark - Setter
- (NSArray <NSDictionary *>*)DataArr
{
    if (!_DataArr)
    {
        _DataArr = @[
                     @{@"Title":@"资金提现审核",@"Img":@"icon_cpital_audit_default"},
                     @{@"Title":@"星币提现审核",@"Img":@"icon_star_audit_default"},
                     @{@"Title":@"套餐提现审核",@"Img":@"icon_package_default"},
                     @{@"Title":@"退出",@"Img":@"icon_package_default"}
                     ];
    }
    return _DataArr;
}
@end

